package com.example.express.model;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
public class TransHistory {
    private int sn;
    private Timestamp actTime;
    private int uidFrom;
    private int uidTo;
    private Double x;
    private Double y;
    private TransPackage transPackage;

    @Id
    @Column(name = "SN")
    public int getSn() {
        return sn;
    }

    public void setSn(int sn) {
        this.sn = sn;
    }

    @Basic
    @Column(name = "ActTime")
    public Timestamp getActTime() {
        return actTime;
    }

    public void setActTime(Timestamp actTime) {
        this.actTime = actTime;
    }

    @Basic
    @Column(name = "UIDFrom")
    public int getUidFrom() {
        return uidFrom;
    }

    public void setUidFrom(int uidFrom) {
        this.uidFrom = uidFrom;
    }

    @Basic
    @Column(name = "UIDTo")
    public int getUidTo() {
        return uidTo;
    }

    public void setUidTo(int uidTo) {
        this.uidTo = uidTo;
    }

    @Basic
    @Column(name = "x")
    public Double getX() {
        return x;
    }

    public void setX(Double x) {
        this.x = x;
    }

    @Basic
    @Column(name = "y")
    public Double getY() {
        return y;
    }

    public void setY(Double y) {
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TransHistory that = (TransHistory) o;
        return sn == that.sn &&
                uidFrom == that.uidFrom &&
                uidTo == that.uidTo &&
                Objects.equals(actTime, that.actTime) &&
                Objects.equals(x, that.x) &&
                Objects.equals(y, that.y);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sn, actTime, uidFrom, uidTo, x, y);
    }

    @ManyToOne
    @JoinColumn(name = "PackageID", referencedColumnName = "ID", nullable = false)
    public TransPackage getTransPackage() {
        return transPackage;
    }

    public void setTransPackage(TransPackage transPackage) {
        this.transPackage = transPackage;
    }
}
